#include <iostream>
#include <cmath>
using namespace std;

void solve()
{
    int n; cin >> n;
    int i = 0;
    for(i = 30; i >= 0; i--)
    {
        int t = n & (1 << i);
        if(t) break;
    }
    int ans = pow(2, i);
    if(ans == n) cout << -1 << endl;
    else cout << ans << endl;
}

int main()
{
    int t; cin >> t;
    while(t--) solve();
    return 0;
}